package com.extremeforce.module;

import java.util.ArrayList;
import java.util.HashMap;

import com.extremeforce.R;
import com.extremeforce.adapter.MyCouponListAdapter;
import com.extremeforce.db.DBMaster;
import com.extremeforce.function.GetNetImage;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListView;

public class MyCouponActivity extends Activity{

	private ListView listView;
	private ArrayList<HashMap<String,Object>> list ;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mycouponlayout);
		list = new ArrayList<HashMap<String,Object>>();
		listView = (ListView)findViewById(R.id.mycouponList);
		
		DBMaster dbMaster = new DBMaster(this);
		Cursor cursor = dbMaster.getMyCoupon();
		while(cursor.moveToNext()){
			HashMap<String,Object> map = new HashMap<String,Object>();
			String coupon_serial = cursor.getString(cursor.getColumnIndex("COUPON_SERIAL"));
			String coupon_title = cursor.getString(cursor.getColumnIndex("COUPON_TITLE"));
			String coupon_desc = cursor.getString(cursor.getColumnIndex("COUPON_DESC"));
			byte[] array = cursor.getBlob(cursor.getColumnIndex("COUPON_IMAGE"));
			String date = cursor.getString(cursor.getColumnIndex("GET_DATE"));
			map.put("serial",coupon_serial);
			map.put("title",coupon_title);
			map.put("desc",coupon_desc);
			map.put("image",array);
			map.put("date",date);
			
			list.add(map);
		}
		cursor.close();
		dbMaster.close();
		
		
		MyCouponListAdapter mcla = new MyCouponListAdapter(list,this);
		
		listView.setAdapter(mcla);
	}

	
}
